package com.lagou.rabbitmq.demo.controller;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class PayController {

  @Autowired
  private AmqpTemplate rabbitTemplate;

  @RequestMapping("/order")
  public String order() {
    rabbitTemplate.convertAndSend("ex.go", "go", "支付超时");
    return "ok";
  }


  @RequestMapping("/pay")
  public String getAccumulatedTask() {
    String notGo = (String) rabbitTemplate.receiveAndConvert("q.go.dlx");

    System.out.println("dlx ="+ notGo);

    if(notGo==null)return "succ";
    else return "fail";
  }



}
